package com.google.samples.apps.databinging.binding

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.BindingAdapter
import com.google.samples.apps.library_common.extension.load

/**
 * Created by Administrator on 2021/7/9 0009.
 * Describe:
 */

@BindingAdapter("app:image")
fun image(view: ImageView, url: String) {
    view.load(url)
}

@BindingAdapter("app:image")
fun image(view: ImageView, res: Int) {
    view.load(res)
}

@BindingAdapter("app:goneUnless")
fun goneUnless(view: View, visible: Boolean) {
    view.visibility = if (visible) View.VISIBLE else View.GONE
}

@BindingAdapter("testText")
fun setTestText(view: TextView, text: CharSequence) {
    view.text = text
}